package org.dk.controller;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.dk.domain.DataResult;
import org.dk.em.DataResultEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("phoneController")
@Controller
public class PhoneController {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;
    @RequestMapping("phoneMessage")
    @ResponseBody
    public DataResult phoneMessage(String phone){
        try {
            rocketMQTemplate.convertAndSend("phone-topic",phone);
            return DataResult.buildDataResult(DataResultEnum.SUCCESS);
        }catch (Exception e){
            return DataResult.buildDataResult(DataResultEnum.ERROR);
        }

    }
}
